-- ReportController

local ReportView = import("..views.ReportView")

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ControllerBase)

function ClassRef:ctor(params)
	self.super.ctor(self, params)

end

function ClassRef:init()
	self._model = app:getInst("PlayerModel")

end

function ClassRef:openView(data)
    if cc.isDead(self._view) then
        self._view = ReportView.new(app.mvc.VIEWTYPE_BLUR)
        self._view:onCloseView(handler(self, self.closeView))
        self._view:onClearView(handler(self, self.clearView))
        self._view:onOperate(handler(self, self.onOperate))
        self:addChild(self._view, data)
    end

    self._view:show()
    self._view:refresh(data)
end

function ClassRef:closeView(data)
    if self._view then
        self:removeChild(self._view, data)
        self:clearView()
    end
end

function ClassRef:clearView()
    if self._view then
        self._view = nil
    end
end

-------------------------------------------------------
function ClassRef:onOperate(op, data)
    print("ReportController:onOperate op="..op)
    if op == "reqSecReport" then
        self._model:reqSecReport(data)
    end
end

return ClassRef